// "foreach: someExpression" is equivalent to "template: { foreach: someExpression }"
// "foreach: { data: someExpression, afterAdd: myfn }" is equivalent to "template: { foreach: someExpression, afterAdd: myfn }"
ko.bindingHandlers['tileviewbinding'] = {  
    'addTile': function(element) {
        var theTile = $(element).children('.tile-view-tile');
        $(element).tileview('addTile',theTile);        
    },
    'init': function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {       
        var ret = ko.bindingHandlers['template']['init'](element, ko.bindingHandlers['foreach'].makeTemplateValueAccessor(valueAccessor));
        ko.bindingHandlers['tileviewbinding'].addTile(element);
        return ret;
    },
    'update': function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
        var ret = ko.bindingHandlers['template']['update'](element, ko.bindingHandlers['foreach'].makeTemplateValueAccessor(valueAccessor), allBindingsAccessor, viewModel, bindingContext);
        ko.bindingHandlers['tileviewbinding'].addTile(element);
        return ret;
    }
};
ko.jsonExpressionRewriting.bindingRewriteValidators['tileviewbinding'] = false; // Can't rewrite control flow bindings
ko.virtualElements.allowedBindings['tileviewbinding'] = true;